<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>欢迎页面-X-admin2.2</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="stylesheet" href="../css/font.css">
		<link rel="stylesheet" href="../css/xadmin.css">
		<script src="../lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="../js/xadmin.js"></script>
		<script src="../js/global.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
	<div class="x-nav">
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
		<!-- 修改div开始 -->
<div id="updatediv" style="display: none;" >
	<form class="layui-form"  lay-filter="updateform" id="updateform" style="margin-top: 20px;">
	  <div class="layui-form-item">
	    <label class="layui-form-label">权重:</label>
	    <div class="layui-input-block">
	      <input type="text" name="weight"  class="layui-input" style="width: 200px;">
	      <input type="hidden" name="askername"  class="layui-input" style="width: 200px;">
	      <input type="hidden" name="checkstate"  class="layui-input" style="width: 200px;">
	      <input type="hidden" name="checkintime"  class="layui-input" style="width: 200px;">
	      <input type="hidden" name="changestate"  class="layui-input" style="width: 200px;">
	      <input type="hidden" name="rolename"  class="layui-input" style="width: 200px;">
	      <input type="hidden" name="bakcontent"  class="layui-input" style="width: 200px;">
	      <input type="hidden" name="askerid"  class="layui-input" style="width: 200px;">
	    </div>
	  </div>
	 
	  <div class="layui-form-item" style="width: 200px;" >
	    <div class="layui-input-block" style="width: 200px;">
	     	<a class="layui-btn" lay-filter="updateBtn" lay-submit=''>修改</a>
	    </div>
	  </div>
  </form>
	</div>
<!-- 修改div结束 -->

		 <div class="layui-card-body ">
                            <table id="demo" lay-filter="test">
								<form class="layui-form" method="post" onsubmit="return false;">
									<div class="layui-form-item">
										  <div class="layui-inline">
										    <label class="layui-form-label">咨询师名称</label>
										    <div class="layui-input-inline" style="width: 100px;">
										      <input type="text" id="q" class="layui-input">
										    </div>
										  </div>
										  <div class="layui-inline">
										    <label class="layui-form-label">签到状态</label>
										    <div class="layui-input-inline" style="width: 100px;">
										      <select class="layui-input" id="b">
										      	<option value='' >--请选择--</option>
										      	<option value='已签到' >已签到</option>
										      	<option value='未签到' >未签到</option>
										      </select>
										    </div>
										  </div>
										  <div class="layui-inline">
										    <label class="layui-form-label">角色</label>
										    <div class="layui-input-inline">
										    	 <input type="text" id="aa" class="layui-input">
										    </div>
										  </div>
										   
										  <div class="layui-inline">
										    <div class="layui-input-inline" style="width: 100px;">
										      <a class="layui-btn" id="search" data-type="reload">查询</a>
										    </div>
										  </div>
									</div>
								</form>
								
							<!--	<div class="layui-card-body ">
									<form class="layui-form" method="post" onsubmit="return false;">
										<div class="layui-input-inline">
											<div class="layui-form" style="width: 100px;">
												<select id="type">
													<option value="1">自动分配</option>
													<option value="0">手动分配</option>
												</select>
											</div>

										</div>
										<div class="layui-inline layui-show-xs-block">
											<button id="set" class="layui-btn" lay-submit>修改</button>
										</div>

								
										
									</form>
								</div>-->
							</table>
                        </div>
	</body>
	<script type="text/html" id="topDemo">
			自动分配咨询师<input type="checkbox" id="zdfp" lay-skin="switch" lay-text="开|关" lay-filter="zxsDemo" >
		</script>
	
	
	 <script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
	</script>
	
	<script type="text/javascript" >
		layui.use(['form','table','layer','laydate', 'transfer'],function(){
			var form=layui.form;
			var $=layui.$;
			var table=layui.table;
			var layer=layui.layer;
			var laydate = layui.laydate;
			transfer = layui.transfer;
			
		/*	getType();
			function getType() {
			$.post("http://localhost:8080/selectType",{
			"token": globalData.getCurToken()
			},function(res) {
			$( "#type").val(res);
			form.render();
			if(res == 1) {
			}else{
			}
			},"json");
			}*/
			table.render({
			  elem: '#demo',
			  url:"http://localhost:8080/getAsker",
				where:{'token':globalData.getCurToken()},
					method:"post",
					
			  page:true,
			 // toolbar:'#bar',
			  toolbar:"#topDemo",
			  parseData:function(res){
				  return{
					  "code":0,
					  "msg":"1",
					  "count":res.totalElements,
					  "data":res.content
				  }
			  },
			  
			  cols:[
				  [
					  
					  {field:'askername',title:'咨询师名称'},
					  {field:'checkstate',title:'签到状态'},
					  {field:'checkintime',title:'签到时间'},
					  {field:'weight',title:'权重'},
					   {field:'rolename',title:'角色'},
					  //{title:'角色',templet:'<span>{{d.roles.Name}}</span>'},
					  {title:'操作',toolbar:'#barDemo'}
					  ]
					],id:'a'
			});
			
			active={
					reload:function(){
						var askername=$("#q").val();
						var rolename=$("#aa").val();
						var checkstate=$("#b").val();
						table.reload('a',{
							where:{
								
								"askername":askername,
								"rolename":rolename,
								"checkstate":checkstate
							}
					})
				}
			}
			
			table.on('edit(test)', function(obj) {
				
				$.post(globalData.server + "update?" + obj.field + "=" + obj.value, {
					"askerid": obj.data.askerid,
					//'pvalue': 'asker-update',
					"token": globalData.getCurToken()
				}, function(res) {
					if(res > 0) {
						layer.msg("修改成功！", {
							icon: 1
						});
					} else {
						layer.msg("修改失败！", {
							icon: 7
						});
					}
				}, "json");
			});
				
					form.on('switch(zxsDemo)', function(obj){
                if(!obj.elem.checked){
                	zdfpzxs=0;
                	localStorage.value=zdfpzxs;
                	layer.msg("修改成功");
                }else{
                	zdfpzxs=1;
                	localStorage.value=zdfpzxs;
                	layer.msg("修改成功");
                }
            });
				
				var zdfpzxs=localStorage.value;
			zdfpzxs=zdfpzxs+"";
			if("0"==zdfpzxs){
				$('#zdfp').prop('checked','');
			}else{
				$('#zdfp').prop('checked','checked');
			}

				
				/*$('#set').on('click', function() {
				var zdfpzxs=$("#type").val();
				localStorage.value=zdfpzxs;
				layer.msg("修改成功");
			});
				*/
			//监听右侧工具条
			table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
			  var data = obj.data; //获得当前行数据
			  var layEvent = obj.event; //获得 lay-event 对应的值
			   if(layEvent === 'edit'){ //编辑
				  	form.val('updateform',data);
				  	layer.open({
				  		type:1,
				  		area:['400px','200px'],
				  		content:$("#updatediv")
				  	})
			  }
			});
			
			//修gai
			form.on('submit(updateBtn)',function(){
				$.post('http://localhost:8080/updteAsker',$("#updateform").serialize()+'&token='+globalData.getCurToken(),function(res){
					if(res>0){
						layer.closeAll();
						layer.msg("修改成功");
						window.location.reload();
					}
				},"json")
			})
		
				
			
			$("#search").on('click',function(){
				active.reload();
			})
		})
	</script>
</html>
